import type { ProfitPredictionInputData } from '@/types/profit-prediction';
import type { CommonResult } from '@/types/global';
import { http } from '@/utils/http';

// 接口前缀
const API_PREFIX = '/shopmanager/mobile';

/**
 * 保存或更新盈利预测数据
 * 如果数据已存在则更新，否则新建
 * @param data 盈利预测数据
 * @returns 保存结果
 */
export const saveProfitPredictionAPI = (data: ProfitPredictionInputData) => {
	return http<CommonResult>({
		url: `${API_PREFIX}/profitPredictions/save`,
		method: 'POST',
		data
	});
};

/**
 * 获取盈利预测数据
 * @param taskId 任务ID
 * @returns 盈利预测数据
 */
export const getProfitPredictionAPI = (taskId: number) => {
	return http<ProfitPredictionInputData>({
		url: `${API_PREFIX}/profitPredictions/getByTaskId/${taskId}`,
		method: 'GET'
	});
};

